package com.wltt.product.frfront.controller;

import com.wltt.product.frfront.model.ResultData;
import com.wltt.product.frfront.model.vo.*;
import com.wltt.product.frfront.service.SystemUserService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/api/systemUser")
public class SystemUserController {

    private static final Logger logger = LogManager.getLogger(SystemUserController.class);

    @Resource
    private SystemUserService systemUserService;

    /**
     * 查询所有系统用户
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/allSystemUser"}, method = RequestMethod.POST)
    public ResultData allSystemUser() {
        return systemUserService.allSystemUser();
    }

    /**
     * 系统用户详情
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/systemUserDetail"}, method = RequestMethod.POST)
    public ResultData systemUserDetail(@RequestBody SystemUserDetailREQ systemUserDetailREQ) {
        return systemUserService.systemUserDetail(systemUserDetailREQ);
    }

    /**
     * 新增系统用户
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/addSystemUser"}, method = RequestMethod.POST)
    public ResultData addSystemUser(@RequestBody AddSystemUserREQ addSystemUserREQ) {
        return systemUserService.addSystemUser(addSystemUserREQ);
    }

    /**
     * 更新系统用户
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/updateSystemUser"}, method = RequestMethod.POST)
    public ResultData updateSystemUser(@RequestBody UpdateSystemUserREQ updateSystemUserREQ) {
        return systemUserService.updateSystemUser(updateSystemUserREQ);
    }

    /**
     * 更新密码
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/updatePassword"}, method = RequestMethod.POST)
    public ResultData updatePassword(@RequestBody UpdatePasswordREQ updatePasswordREQ) {
        return systemUserService.updatePassword(updatePasswordREQ);
    }

    /**
     * 删除系统用户
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/deleteSystemUser"}, method = RequestMethod.POST)
    public ResultData deleteSystemUser(@RequestBody DeleteSystemUserREQ deleteSystemUserREQ) {
        return systemUserService.deleteSystemUser(deleteSystemUserREQ);
    }

}
